home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / a_utils / perl / prlbkxmp.lha / ch6 / pchelp < prev    next >
Text File  |  1991-01-08  |  2KB  |  152 lines

  1. #!/usr/bin/perl
  2.  
  3. $TEMP = "/tmp/pchelp$$";
  4.  
  5. $DEST = 'pctech@technics.pyro.edu';
  6.  
  7. $login = $ENV{'USER'} || getlogin;
  8. $gcos = (getpwnam($login))[6];
  9. ($name, $loc, $ext) = split(/,/, $gcos);
  10.  
  11. $EDITOR = $ENV{"VISUAL"} || $ENV{"EDITOR"} || "vi";
  12. $PAGER = $ENV{"PAGER"} || "more";
  13.  
  14. open(FORM, ">$TEMP") || die "Can't create temp form: $!\n";
  15.  
  16. system 'clear';
  17. chop($prompt = <<'EOP');
  18.  
  19. What do you want to do?
  20.  
  21.     a)      PC problem report
  22.     b)      Software order request
  23.     c)      Hardware order request
  24.     q)      Quit
  25.  
  26. Select an option [q]: 
  27. EOP
  28.  
  29. print $prompt;
  30. ($ans = substr(<STDIN>,0,1)) =~ y/A-Z/a-z/;
  31.  
  32. {
  33.     goto problem    if $ans eq 'a';
  34.     goto software   if $ans eq 'b';
  35.     goto hardware   if $ans eq 'c';
  36.     goto end;
  37. }
  38.  
  39. whatnow: {
  40.  
  41.     print "\nWhat now? ";
  42.  
  43.     ($ans = substr(<STDIN>,0,1)) =~ y/A-Z/a-z;
  44.  
  45.     goto mail       if $ans eq 's';
  46.     goto edit       if $ans eq 'e';
  47.     goto end        if $ans eq 'a';
  48.     goto end        if $ans eq 'q';
  49.     goto list       if $ans eq 'l';
  50.     goto help;
  51. }
  52.  
  53.  
  54. help: {
  55.     print "Options are:\n";
  56.     print "  abort\n";
  57.     print "  edit\n";
  58.     print "  list\n";
  59.     print "  send\n";
  60.  
  61.     goto whatnow;
  62. }
  63.  
  64. problem: {
  65.  
  66.     print FORM <<EOF;
  67.  
  68.     Name: $name
  69.      Badge #: 
  70.     Location: $loc
  71.        Phone: $ext
  72. Machine type: 
  73.     Serial #: 
  74.   Property #: 
  75.  
  76. Description of problem:
  77.  
  78. EOF
  79.  
  80.     goto edit;
  81.  
  82. } # end problem
  83.  
  84. software: {
  85.  
  86.     print FORM <<EOF;
  87.  
  88.     Name: $name
  89.      Badge #: 
  90.     Location: $loc
  91.        Phone: $ext
  92. Machine type: 
  93.     Serial #: 
  94.   Property #: 
  95.    Account #: 
  96.  
  97. Software requested:
  98.  
  99.  
  100. Comments:
  101.  
  102. EOF
  103.  
  104.     goto edit;
  105.  
  106. } # end software
  107.  
  108. hardware: {
  109.  
  110.     print FORM <<EOF;
  111.  
  112.     Name: $name
  113.      Badge #: 
  114.     Location: $loc
  115.        Phone: $ext
  116.    Account #: 
  117.   Supervisor: 
  118.  
  119. Description of hardware desired (be specific):
  120.  
  121. EOF
  122.  
  123.     goto edit;
  124.  
  125. } # end hardware
  126.  
  127. edit: {
  128.     close FORM;
  129.     print "\nInvoking editor, $EDITOR...\n";
  130.     sleep (1);
  131.     system $EDITOR, $TEMP;
  132.     goto whatnow;
  133. }
  134.  
  135.  
  136. mail: {
  137.     print "\nMailing to $DEST...\n";
  138.     system "/bin/mail $DEST </tmp/pchelp$$";
  139.     goto end;
  140. }
  141.  
  142.  
  143. list: {
  144.     system $PAGER, "/tmp/pchelp$$";
  145.     goto whatnow;
  146. }
  147.  
  148.  
  149. end: {
  150.     unlink $TEMP;
  151. }
  152.